Applying Transfer Modes to Bitmaps
When drawing a bitmap, QuickDraw GX uses the color information stored in the geometry of the bitmap shape; it ignores the color information stored in the ink object associated with the bitmap shape.However, QuickDraw GX does consider the transfer mode information specified in a bitmap shape's ink object. QuickDraw GX uses the transfer mode when drawing each pixel of a bitmap.
As an example, the sample function in Listing 5-8 creates a rectangle shape containing a purple rectangle and a bitmap shape containing a color ramp from red to green (as defined in Listing 5-6 on page 5-29).
Listing 5-8 Applying a transfer mode to a bitmap
void ApplyTransferModeToBitmap(void) { gxShape aRectangleShape, aBitmapShape; const gxRectangle theRectangleBounds = {ff(100), ff(100), ff(200), ff(200)}; const gxRectangle theBitmapBounds = {ff(50), ff(50), ff(150), ff(150)}; gxColor start, end; aRectangleShape = GXNewRectangle(&theRectangleBounds); SetShapeCommonColor(aRectangleShape, purple); SetCommonColor(&start, red); SetCommonColor(&end, green); aBitmapShape = NewRamp(&start, &end, 0, &theBitmapBounds); SetShapeCommonTransfer(aBitmapShape, gxBlendMode); GXDrawShape(aRectangleShape); GXDrawShape(aBitmapShape); GXDisposeShape(aRectangleShape); GXDisposeShape(aBitmapShape); }The sample function then uses the transfer mode library functionSetShapeCommonTransfer
to set the transfer mode of the bitmap shape togxBlendMode
.Finally, the sample function draws the purple rectangle and the bitmap. Since the ink object associated with the bitmap specifies the
gxBlendMode
transfer mode, QuickDraw GX applies this transfer mode when drawing each pixel of the bitmap. Pixels that fall over the white background are blended with white, and pixels that fall over the purple rectangle are blended with purple.Figure 5-17 shows the result of this sample function. For a color version of this figure, see Plate 2 at the front of this book.
Figure 5-17 A blended color ramp
You can find more information about transfer modes in the chapter "Ink Objects" in Inside Macintosh: QuickDraw GX Objects.
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help